< previous page page_548 next page >

Page 548
Tip.gif
Notice the use of the CommonDialog control to open the file. Whenever you need to prompt users for file-related action (open, create, save), you should use the CommonDialog control. This is a familiar dialog for your users, and it handles all of the dirty work of scrolling, searching, and so on.

Table 14.2 lists errors that are similar to the File not found error illustrated in Listing 14.9. Errors of this type usually involve giving the user a chance to re-enter the filename or reset some value. Most of the time, you can write an error trap that anticipates these errors, prompts the user to supply the corrected information, and then retries the operation that caused the error.
Table 14.2. Common general file errors.
Error CodeError Message
52Bad filename or number
53File not found
54Bad file mode
55File already open
58File already exists
59Bad record length
61Disk full
62Input past end of file
63Bad record number
64Bad filename
67Too many files
74Can't rename with different drive
75Path/File access error
76Path not found

In cases when it is not practical to prompt a user for additional information (such as during initial startup of the program), it is usually best to report the error in a message box. Then give the user some ideas about how to fix the problem before you exit the program safely.

 
< previous page page_548 next page >

If you like this book, buy it!